﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Weazel.Willows.Model
{
	public partial class Model 
		: HierarchicalEntity
	{
		public RefinedModel.Model Refine()
		{
			System.Diagnostics.Trace.Assert(Top != null);

			RefinedModel.Model refinedModel = 
				new Weazel.Willows.RefinedModel.Model(this);			

			top.Refine(refinedModel);

			top.RefineInterconnections(refinedModel);

			// finally insert a system 
			Weazel.Gezel.Model.system system = 
				new Weazel.Gezel.Model.system(refinedModel, "top_level");

			system.UnconnectedDatapaths.Add(Top.LocalName);	

			refinedModel.Systems.Add(system.LocalName, system);

			return refinedModel;
		}
	}
}
